﻿#region 命名空间

using System;
using System.Web;
using System.Data;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.WebControls;
using WinnerCMS.Data;
using WinnerCMS.Common;
using WinnerCMS.Model;

#endregion

namespace WinnerCMS.BLL
{
    public class BusinessManage : MarshalByRefObject
    {
        private static readonly BusinessDal Dal = new BusinessDal();

        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model"></param>
        [Logging("添加交易记录。"), ExceptionCall]
        public Result Add(Business model)
        {
            Result res = new Result();
            Dal.Add(model);
            return res;
        }

        /// <summary>
        /// 删除数据
        /// </summary>
        /// <param name="ids"></param>
        [Logging("添加交易记录。"), ExceptionCall]
        public Result Delete(string ids)
        {
            Result res = new Result();
            if (string.IsNullOrEmpty(ids))
            {
                res.Errors = "至少选择一项。";
            }
            else
            {
                Dal.Delete(MyConvert.ConvertToArr(ids));
            }
            return res;
        }

        /// <summary>
        /// 绑定交易列表
        /// </summary>
        /// <param name="flag"></param>
        /// <param name="pp"></param>
        /// <returns></returns>
        public IList<Business> BindList(byte flag, PagingParam pp)
        {
            return Dal.BindList(flag, pp);
        }

        /// <summary>
        /// 检查是否已经支持过
        /// </summary>
        /// <param name="id">内容ID</param>
        /// <param name="userid"></param>
        /// <returns></returns>
        public DateTime? CheckReaded(int id, int userid)
        {
            DateTime? dt = Dal.CheckReaded(id, userid);
            if (dt == DateTime.MinValue)
            {
                dt = null;
            }
            return dt;
        }
    }
}